<?php
defined('_JEXEC') or die('Restricted access');
JToolBarHelper::title(JText::_('COM_JHTRAQ_MILESTONE_ADD_EDIT'), 'generic.png');
JToolBarHelper::save();
JToolBarHelper::cancel();
//JToolBarHelper::preferences('com_jhtraq');
$editor =& JFactory::getEditor();
?>
<?php JHTML::_('behavior.tooltip'); ?>
<?php JHTML::_('behavior.calendar'); ?>
<script language="javascript" type="text/javascript">
function submitbutton(pressbutton) {
	var form = document.adminForm;
	if (pressbutton == 'cancel') {
		submitform( pressbutton );
		return;
	}
	var r = new RegExp("[\<|\>|\"|\'|\%|\;|\(|\)|\&]", "i");
	
	// do field validation
	//if (trim(form.name.value) == "") {
	//	alert( "<?php echo JText::_( 'COM_JHTRAQ_MUST_NAME', true ); ?>" );
	//} else if (form.slug.value == "") {
	//	alert( "<?php echo JText::_( 'COM_JHTRAQ_MUST_SLUG', true ); ?>" );
	//}else {
		submitform( pressbutton );
	//}
}
</script>
<form action="index.php?option=com_jhtraq&view=milestones" method="post" name="adminForm">
<input type="hidden" name="task" value="" />
<input type="hidden" name="id" value="<?php echo (int)$this->milestone->id;?>" />

<table class="adminlist" cellpadding="1">
<tr>
	<td width="150"><label for="milestone"><?php echo JText::_('COM_JHTRAQ_MILESTONE');?></label></td>
	<td><input type="text" name="milestone" id="milestone" value="<?php echo @$this->milestone->milestone;?>" class="inputbox" /></td>
</tr>
<tr>
	<td width="150"><label for="slug"><?php echo JText::_('COM_JHTRAQ_MILESTONE_SLUG');?></label></td>
	<td><input type="text" name="slug" id="slug" value="<?php echo @$this->milestone->slug;?>" class="inputbox" /></td>
</tr>
<tr>
	<td width="150"><label for="codename"><?php echo JText::_('COM_JHTRAQ_MILESTONE_CODENAME');?></label></td>
	<td><input type="text" name="codename" id="codename" value="<?php echo @$this->milestone->codename;?>" class="inputbox" /></td>
</tr>
<tr>
	<td width="150"><label for="project_id"><?php echo JText::_('COM_JHTRAQ_PROJECT');?></label></td>
	<td><select name="project_id" id="project_id">
	<?php
	foreach($this->projects as $pid=>$pname)
	{
		echo '<option value="'.$pid.'" ';
		if($pid == @$this->milestone->project_id) echo 'SELECTED';
		echo '>' . $pname . '</option>';
	}
	?></select>
	</td>
</tr>
<tr>
	<td width="150"><label for="due"><?php echo JText::_('COM_JHTRAQ_DUE_DATE');?></label></td>
	<td><input class="inputbox" type="text" name="due"
	id="due" size="25" maxlength="25"
	value="<?php echo (@$this->milestone->due > 0) ?DATE(JText::_('COM_JHTRAQ_MILESTONE_DATE'), $this->milestone->due):'';?>" />
	<?php JHTML::calendar(@$this->milestone->due, "due", "due");?>
</tr>
<tr>
	<td width="150"><label for="info"><?php echo JText::_('COM_JHTRAQ_MILESTONE_DETAILS');?></label></td>
	<td><?php
	// parameters : areaname, content, width, height, cols, rows
	echo $editor->display( 'info',  @$this->milestone->info, '550', '300', '60', '20', array() ) ;
	?></td>
</tr>
<?php if(@$this->milestone->id > 0)
{
	?>
<tr>
<td width="150"><label for="changelog"><?php echo JText::_('COM_JHTRAQ_MILESTONE_CHANGELOG');?></label></td>
	<td><?php
	// parameters : areaname, content, width, height, cols, rows
	echo $editor->display( 'changelog',  $this->milestone->changelog, '550', '300', '60', '20', array() ) ;
	?></td>
</tr>
<?php
}
?>
<tr>
	<td width="150"><label for="displayorder"><?php echo JText::_('COM_JHTRAQ_MILESTONE_ORDERING');?></label></td>
	<td><input type="text" name="displayorder" id="displayorder" value="<?php echo @$this->milestone->displayorder;?>" class="inputbox" size="3"/></td>
</tr>
<tr>
	<td width="150"><label for="status"><?php echo JText::_('COM_JHTRAQ_STATUS');?></label></td>
	<td><select name="status">
		<option value="active"><?php echo JText::_('COM_JHTRAQ_ACTIVE');?></option>
		<option value="completed" <?php if(@$this->milestone->completed > 0) echo ' selected';?>><?php echo JText::_('COM_JHTRAQ_COMPLETED');?></option>
		<option value="cancelled" <?php if(@$this->milestone->cancelled > 0) echo ' selected';?>><?php echo JText::_('COM_JHTRAQ_CANCELED');?></option>
		</select>
		<input type="hidden" name="completed" value="<?php echo $this->milestone->completed;?>">
		<input type="hidden" name="cancelled" value="<?php echo $this->milestone->cancelled;?>">
	</td>
</tr>
</table>
</form>